Skip to content

Add the Multi-Tenant Catalogs Endpoint Extension, for nested catalog support#366

Open
jonhealy1 wants to merge 52 commits into
stac-utils:mainfrom
jonhealy1:stac-fastapi-catalogs-extension
Open

Add the Multi-Tenant Catalogs Endpoint Extension, for nested catalog support#366
jonhealy1 wants to merge 52 commits into
stac-utils:mainfrom
jonhealy1:stac-fastapi-catalogs-extension

Conversation

@jonhealy1
Copy link
Copy Markdown
Collaborator

@jonhealy1 jonhealy1 commented Mar 25, 2026

Related Issue(s):

Description:

Extension spec: https://github.com/StacLabs/multi-tenant-catalogs
STAC-FastAPI catalogs extension: https://github.com/StacLabs/stac-fastapi-catalogs-extension

PR Checklist:

  • pre-commit hooks pass locally
  • Tests pass (run make test)
  • Documentation has been updated to reflect changes, if applicable, and docs build successfully (run make docs)
  • Changes are added to the CHANGELOG.

@jonhealy1
Copy link
Copy Markdown
Collaborator Author

It's going to be best to fix the extension so it supports python 3.11

@jonhealy1 jonhealy1 changed the title route extension, create, get catalogs Add the Multi-Tenant Virtual Catalogs Extension, for nested catalog support Mar 25, 2026
@jonhealy1 jonhealy1 changed the title Add the Multi-Tenant Virtual Catalogs Extension, for nested catalog support Add the Multi-Tenant Catalogs Endpoint Extension, for nested catalog support Mar 25, 2026
Comment thread stac_fastapi/pgstac/extensions/catalogs/catalogs_database_logic.py Outdated
@jonhealy1
Copy link
Copy Markdown
Collaborator Author

jonhealy1 commented Apr 21, 2026

This is really close to being reviewable, just need some time to do some qa, documentation.

@jonhealy1
Copy link
Copy Markdown
Collaborator Author

jonhealy1 commented May 3, 2026

@bkanuka Thanks for the feedback. I have implemented the two suggestions you made. Removing parent_ids from collection responses and fixing/ improving the self link generation.

@jonhealy1 jonhealy1 requested review from bitner, bkanuka, hrodmn and vincentsarago and removed request for bkanuka May 3, 2026 04:41
Comment thread stac_fastapi/pgstac/app.py Outdated
Comment thread stac_fastapi/pgstac/app.py Outdated
Comment thread stac_fastapi/pgstac/app.py
Comment thread stac_fastapi/pgstac/app.py Outdated
Comment thread stac_fastapi/pgstac/app.py Outdated
Comment thread tests/conftest.py Outdated
@jonhealy1 jonhealy1 requested a review from vincentsarago May 6, 2026 05:10
@jonhealy1
Copy link
Copy Markdown
Collaborator Author

@vincentsarago Thanks for reviewing. I have implemented most of your suggestions - except for the name change.

I have also updated the catalogs extension to v0.2.0 which basically just means a separate catalogs transactions class. My thinking is that the catalogs transaction routes will only be implemented when the core transaction extension is enabled. This may be too simplistic, let me know what you think.

Additionally I added some documentation to the readme and settings.md.

Comment thread stac_fastapi/pgstac/app.py Outdated
Comment on lines +94 to +123
catalog_id = cast(str, catalog.get("id"))
parent_ids_raw = catalog.get("parent_ids", [])
parent_ids: list[str] = (
cast(list[str], parent_ids_raw)
if isinstance(parent_ids_raw, list)
else ([cast(str, parent_ids_raw)] if parent_ids_raw else [])
)

# Get child catalogs for link generation
child_catalogs, _, _ = await self.database.get_sub_catalogs(
catalog_id=catalog_id,
limit=1000,
request=request,
)
child_catalog_ids: list[str] = (
[cast(str, c.get("id")) for c in child_catalogs]
if child_catalogs
else []
)

# Generate links
catalog["links"] = await CatalogLinks(
catalog_id=catalog_id,
request=request,
parent_ids=parent_ids,
child_catalog_ids=child_catalog_ids,
).get_links(extra_links=catalog.get("links"))

# Remove internal metadata before returning
catalog.pop("parent_ids", None)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link generation code is repeated a couple times - roughly line 172 and 260. I think it would make sense to pop it out to a (static) _generate_catalog_links method.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the logic could go into the existing _build_response_links ? Sorry I don't have the brain space to come up with the solution right now!

"""
await self.database.delete_catalog(catalog_id, refresh=True, request=request)

def _rewrite_collection_links(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and a couple more _ methods could be static.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants